package com.hey.consumerfeign.service;

import com.hey.consumerfeign.entity.Testx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import reactor.core.publisher.Flux;

import java.util.List;

@FeignClient(value = "service-01",fallback = TestService.Fallback.class)
public interface TestService {

    @GetMapping(value = "list")
    Flux<List<Testx>> findAll();

    @Component
    class Fallback implements TestService{

        @Autowired
        private DiscoveryClient discoveryClient;

        @Override
        public Flux<List<Testx>> findAll() {
            discoveryClient.getServices();
            return null;
        }
    }
}
